--固规无涉
local guguiwushe = fk.CreateSkill {
    name = "mcdh_guguiwushe",
    tags ={Skill.Compulsory}
}

local U = require "packages/utility/utility"
local lib = require "packages/mcdh/lib"

guguiwushe:addEffect(fk.Damaged,{
    can_trigger = function(self, event, target, player, data)
        return  player:hasSkill(self) and player:usedSkillTimes(self.name,Player.HistoryTurn) == 0 and target == player
    end,
    on_use = function(self, event, target, player, data)
        local room = player.room
        local tar = room:askToChoosePlayers(player, {
            targets = room:getOtherPlayers(player),
            min_num = 1,
            max_num = 1,
            prompt = "#mcdh_guguiwushe",
            skill_name = self.name,
            cancelable = false,
            no_indicate = false,
            target_tip_name = "mcdh_distance_tip"
          })
        tar = tar[1]
        local  num = player:distanceTo(tar)
        local choices = {"mcdh_guguiwushe1:::"..num,"mcdh_guguiwushe2:::"..num}
        local choice = room:askForChoice(player, choices, self.name)
        if choice == "mcdh_guguiwushe1:::"..num then
            tar:drawCards(num,self.name)
            local dis = 2
            room:askForDiscard(tar, dis ,dis, true, self.name, false, ".", "#guguiwushe-discard:::"..dis)
        else
            --函数内部不足会自动弃置
            room:askForDiscard(tar, num, num, true, self.name, false, ".", "#guguiwushe-discard:::"..num)
            tar:drawCards(2,self.name)
        end
    end
})

guguiwushe:addEffect(fk.Damage,{
    can_trigger = function(self, event, target, player, data)
        return  player:hasSkill(self) and player:usedSkillTimes(self.name,Player.HistoryTurn) == 0 and target == player
    end,
    on_use = function(self, event, target, player, data)
        local room = player.room
        local tar = room:askToChoosePlayers(player, {
            targets = room:getOtherPlayers(player),
            min_num = 1,
            max_num = 1,
            prompt = "#mcdh_guguiwushe",
            skill_name = self.name,
            cancelable = false,
            no_indicate = false,
            target_tip_name = "mcdh_distance_tip"
          })
        tar = tar[1]
        local  num = player:distanceTo(tar)
        local choices = {"mcdh_guguiwushe1:::"..num,"mcdh_guguiwushe2:::"..num}
        local choice = room:askForChoice(player, choices, self.name)
        if choice == "mcdh_guguiwushe1:::"..num then
            tar:drawCards(num,self.name)
            local dis = 2
            room:askForDiscard(tar, dis ,dis, true, self.name, false, ".", "#guguiwushe-discard:::"..dis)
        else
            --函数内部不足会自动弃置
            room:askForDiscard(tar, num, num, true, self.name, false, ".", "#guguiwushe-discard:::"..num)
            tar:drawCards(2,self.name)
        end
    end
})

Fk:loadTranslationTable {
    ["mcdh_guguiwushe"] = "固规无涉",
    [":mcdh_guguiwushe"] = "锁定技,每回合限一次，当你造成或受到伤害后,你选择一名其他角色并令其执行一项:1.摸X张牌,然后弃置两张牌(不足全弃）;2.弃置X张牌(不足全弃）,摸两张牌。(X为你计算与其的距离）",
    ["mcdh_guguiwushe1"] = "1.摸 %arg 张牌,然后弃置两张牌",
    ["mcdh_guguiwushe2"] = "2.弃置 %arg 张牌,摸两张牌",
    ["#guguiwushe-discard"] = "固规无涉: 弃置 %arg 张牌",
    ["#mcdh_guguiwushe"] = "固规无涉:选择一名其他角色",
}

return guguiwushe